<?php
// +----------------------------------------------------------------------
// | EtrolPHP [ WE CAN DO IT JUST THINK IT ]
// +----------------------------------------------------------------------
// | Author:LJQ <liujiqi@etrol.com>
// +-----------------------------------------------------------------------

namespace app\plan\model;

use app\common\model\Base;
use app\basic\model\Enterprise;
use app\basic\model\Unit;
/**
 * 预案管理
 */
class Plan extends Base{
	protected $name = 'reserveplan';
	protected $createTime = 'createTime';
	protected $updateTime = 'updateTime';
	
	public $planTypeList=[] ;

	public  function getType(){

	 $planType=db('basicinfo')->where(array('sysCode'=>20))->column('subsystemName','subsystemNo');
	 $this->planTypeList=$planType;
	 return $this->planTypeList;
	}


	



	public function gettypeIdAttr($value,$data){
		$this->getType();
		if($data['typeId']){
			return $this->planTypeList[$data['typeId']];
		}
		return null;
	}



	public function enterprise(){

		return $this->hasOne(Enterprise::class,'id','unitId');

	}


	public function unit(){

		return $this->hasOne(Unit::class,'id','unitId');

		
	}

	public function scripts(){
		return $this->hasMany('Script','reservePlanId','id'); 
	}





}